#include "gtest/gtest.h"
#include <vector>
#include <ostream>

// Verifies that the command line flag variables can be accessed
// in code once <gtest/gtest.h> has been #included.
// Do not move it after other #includes.
TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
  bool dummy = testing::GTEST_FLAG(also_run_disabled_tests)
      || testing::GTEST_FLAG(break_on_failure)
      || testing::GTEST_FLAG(catch_exceptions)
      || testing::GTEST_FLAG(color) != "unknown"
      || testing::GTEST_FLAG(filter) != "unknown"
      || testing::GTEST_FLAG(list_tests)
      || testing::GTEST_FLAG(output) != "unknown"
      || testing::GTEST_FLAG(print_time)
      || testing::GTEST_FLAG(random_seed)
      || testing::GTEST_FLAG(repeat) > 0
      || testing::GTEST_FLAG(show_internal_stack_frames)
      || testing::GTEST_FLAG(shuffle)
      || testing::GTEST_FLAG(stack_trace_depth) > 0
      || testing::GTEST_FLAG(stream_result_to) != "unknown"
      || testing::GTEST_FLAG(throw_on_failure);
  EXPECT_TRUE(dummy || !dummy);  // Suppresses warning that dummy is unused.
}

#include "gtest/gtest-spi.h"

// Indicates that this translation unit is part of Google Test's
// implementation.  It must come before gtest-internal-inl.h is
// included, or there will be a compiler error.  This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.

#include <limits.h>  // For INT_MAX.
#include <stdlib.h>
#include <time.h>
#include <map>

#include <Engine/Math/Vec3.h>
#include <Engine/Math/Vec4.h>
#include <Engine/Math/Mat44.h>

TEST(Engine, MathTest)
{
	using namespace fastbird;
	Vec3 x(1, 0, 0);
	Vec3 y(0, 1, 0);
	EXPECT_TRUE(x.Cross(y) == Vec3::UNIT_Z);
}

TEST(Engine, Projection)
{
	using namespace fastbird;
	float theta = 3.141592f/2.f;
	float d = 1.0f/tan(theta/2.f);
	float width = 1920;
	float height= 1080;
	float a = width/height;
	float DofA = d/a;
	float f = 1000.f;
	float n = 10.0f;
	float A = f/(f-n);
	float B = n*f/(n-f);

	Mat44 proj(
		DofA,	0,	0,	0,
		0,		A,	0,	B,
		0,		0,	d,	0,
		0,		1,	0,	0
		);

	Mat44 projYZSwap(
		DofA,	0,	0,	0,		
		0,		0,	d,	0,
		0,		A,	0,	B,
		0,		1,	0,	0
		);

	Vec4 testPosition(0, 10, 10, 1);
	Vec4 result = proj * testPosition;
	Vec4 resultYZSwap = projYZSwap * testPosition;
	Mat44 testProj(
		0.75, 0, 0, 0,
		0, 0, 1, 0,
		0, 1.01, 0, -5.05,
		0, 1, 0, 1);
	Vec4 testPos(1, 0, 1, 1);
	Vec4 re = testProj * testPos;

}